<?php
namespace app\lib\resolution;
class Vnil
{
    protected $appkey = 'c22gv7jhjqq6yucjngme7q62';

    protected $platform = 'douyin';

    public function getAuthorList($uid, $cursor = "")
    {
        $param = [
            "platform" => $this->platform,
            "appkey" => $this->appkey,
            "cursor" => $cursor,
            "uid" => $uid
        ];
        $apiUrl = "http://api.vnil.cn/api/customparse/getlist";
        $result = curlPost($apiUrl,$param);
//        $data_string = json_encode($param);
//        print_r($data_string);
//        $ch = curl_init($apiUrl);
//        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
//        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
//        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
////        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
////            'Content-Type: application/json',
////            'Content-Length: ' . strlen($data_string)
////        ));
//
//        $result = curl_exec($ch);
//        if (curl_errno($ch)) {
//            print curl_error($ch);
//        }
//        curl_close($ch);
        return $result;

    }

    public function getItem($url){

        $param = [
            'appkey'	=> $this->appkey,
            'url'		=> $url,
        ];
        $apiUrl = 'https://api.vnil.cn/api/parse/deal?'.http_build_query($param);

        $ch = curl_init();
        curl_setopt ( $ch, CURLOPT_URL, $apiUrl );
        curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
        curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
        curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
        curl_setopt ( $ch, CURLOPT_MAXREDIRS, 5 );
        curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
        curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
        curl_setopt ( $ch, CURLOPT_TIMEOUT, 10 );
        $content = curl_exec( $ch );
        curl_close ( $ch);

        $result = json_decode($content,true);

        $data = $result["body"];
        return $data;


    }

}